#include <iostream>
#include <unordered_map>

using namespace std;
using LL=long long;
const int N=1e5+10;


LL cal(LL a)
{
	return (LL)a*(a-1)/2;
}
int main()
{
	int n;
	cin>>n;
	unordered_map<LL,int> has;
	for(int i=1;i<=n;i++)
	{
		int num;
		scanf("%d",&num);
		has[(LL)num*i]++;
	}
	
	LL ret=0;
	for(auto &e:has)
	{
		if(e.second>=2)
		{
			ret+=cal(e.second);
		}
	}
	cout<<ret<<endl;
	
	return 0;
}
